package com.ym.im.tcp;

import com.ym.im.tcp.server.LimServer;
import com.ym.im.tcp.server.LimWebSocketServer;
import com.ym.im.codec.config.BootstrapConfig;
import org.yaml.snakeyaml.Yaml;

import java.io.FileInputStream;

public class Starter {

    //    HTTP GET POST PUT DELETE 1.0 1.1 2.0
    //client IOS 安卓 pc(windows mac) web //支持json 也支持 protobuf
    //appId
    //28 + imei + body
    //请求头（指令 版本 clientType 消息解析类型 imei长度 appId bodylen）+ imei号 + 请求体
    //len+body

    public static void main(String[] args)  {
        if(args.length > 0){
            start(args[0]);
        }
    }

    private static void start(String path){
        try {
            Yaml yaml = new Yaml();
            FileInputStream inputStream = new FileInputStream(path);
            BootstrapConfig bootstrapConfig = yaml.loadAs(inputStream, BootstrapConfig.class);

            new LimServer(bootstrapConfig.getLim()).start();
            new LimWebSocketServer(bootstrapConfig.getLim()).start();

        } catch (Exception e) {
            e.printStackTrace();
            System.exit(500);
        }
    }
}
